import request from "@/utils/request"
import type { AttrInfoModel, AttrListModel } from "./model/attrModel"
import type { CategoryId } from "@/api/product/model/category"
enum Api {
  // 获取数据列表
  getAttrListApi = "/admin/product/attrInfoList",
  // 删除属性的API
  deleteAttrApi = "/admin/product/deleteAttr",
  // 添加或更新属性的API
  addOrUpdateAttrApi = "/admin/product/saveAttrInfo",
}

// 获取table展示数据
export const reqGetAttrListData = ({
  category1Id,
  category2Id,
  category3Id,
}: CategoryId) => {
  return request.get<any, AttrListModel>(
    `${Api.getAttrListApi}/${category1Id}/${category2Id}/${category3Id}`
  )
}

// 删除分类
export const reqDeleteAttrValue = (id: number) => {
  return request.delete<any, null>(Api.deleteAttrApi + `/${id}`)
}

// 添加/更新
export const reqAddOrUpdateAttrInfo = (attrInfo: AttrInfoModel) => {
  return request.post<any, null>(Api.addOrUpdateAttrApi, attrInfo)
}
